
// TODO: endian check

static inline uint8_t* cfers_encode_double(uint8_t* out, double d)
{
  *COLFERS_REINTERPRET_CAST(double*,out) = d;
  return out + sizeof(double);
}

static inline uint8_t* cfers_encode_fixed32(uint8_t* out, uint32_t x)
{
  *COLFERS_REINTERPRET_CAST(uint32_t*,out) = x;
  return out + sizeof(uint32_t);
}

static inline uint8_t* cfers_encode_fixed64(uint8_t* out, uint32_t x)
{
  *COLFERS_REINTERPRET_CAST(uint64_t*,out) = x;
  return out + sizeof(uint64_t);
}

static inline uint8_t* cfers_encode_float(uint8_t* out, float x)
{
  *COLFERS_REINTERPRET_CAST(float*,out) = x;
  return out + sizeof(float);
}

static inline uint8_t* cfers_encode_sfixed32(uint8_t* out, uint32_t x)
{
  return cfers_encode_fixed32(out, (x << 1) ^ (x >> 31));
}

static inline uint8_t* cfers_encode_sfixed64(uint8_t* out, uint32_t x)
{
  return cfers_encode_fixed64(out, (x << 1) ^ (x >> 63));
}

